package interface_;

/**
 * @author wly
 * @create 2022-12-06 23:11
 */
public class InterfacePolyArr {
    public static void main(String[] args) {
        Usb[] usbs = new Usb[2];
        usbs[0] = new Phone_();
        usbs[1] = new Camera_();
        for (int i = 0; i < usbs.length; i++) {
            usbs[i].work();
            // 判断运行类型
            if (usbs[i] instanceof Phone_){
                ((Phone_)usbs[i]).call();
            }
        }
    }
}

interface Usb{
    void work();
}

class Phone_ implements Usb{

    public void call(){
        System.out.println("手机能打电话...");
    }

    @Override
    public void work() {
        System.out.println("手机工作...");
    }
}
class Camera_ implements Usb{

    @Override
    public void work() {
        System.out.println("相机工作...");
    }
}

